/*
 * $Id$
 */
package corejs.stmt;

import corejs.rt.ActivationRecord;


import corejs.util.XmlPrinter;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author myang
 */
public class VarDeclaration extends Statement {

   private List<String> _names = new ArrayList<String>();

   public VarDeclaration(final List<String> names) {
      _names = names;
   }

   public VarDeclaration(final String name) {
      _names.add(name);
   }

   public int size() {
      return _names.size();
   }

   public String name(final int index) {
      return _names.get(index);
   }

   @Override
   public void execute(final ActivationRecord scope) {
   }

   @Override
   public void addTo(final Block current) {
      current.addVarDeclaration(this);
   }

   @Override
   public void print(final XmlPrinter printer) {
      printer.open("var");
      for (final String n : _names) {
         printer.print("name", n);
      }
      printer.close();
   }

   @Override
   public void accept(final StatementVisitor visitor) {
      visitor.visitVars(_names);
   }
    
}
